﻿using ConfigServices;
using LogServices;
using MailServices;
using Microsoft.Extensions.DependencyInjection;

namespace ConsoleAppMailSender
{
  internal class Program
  {
    static void Main(string[] args)
    {
      ServiceCollection services = new ServiceCollection();

      //services.AddScoped<IConfigService, EnvVarConfigService>();

      //创建需要属性赋值的服务
      //services.AddScoped(typeof(IConfigService),s=> new IniFileConfigService { FilePath="main.ini"}); //第二个参数为什么要用回调？ =>  因为它不是立马new对象，而是需要使用时才创建
      services.AddIniFileConfigService("main.ini");
      services.AddEnvConfigService();//添加两个配置读取位置，可以实现参数覆盖

      services.AddLayeredConfigReader();

      //services.AddScoped<ILogProvider, ConsoleLogProvider>();
      services.AddConsoleLog();

      services.AddScoped<IMailServiece, MailService>();
      using (var sp=services.BuildServiceProvider())
      {
      var mail=  sp.GetRequiredService<IMailServiece>();
        mail.Send("Hello", "tom", "kkkkkkkkkkaskdjfhakjshflksd");


      }
      Console.ReadLine();
    }
  }
}